home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Utilities / PalmLink / src / PL_Lib.s < prev    next >
Text File  |  2000-05-05  |  12KB  |  380 lines

  1. **
  2. * PalmLink -- Connect 3Com Palm with Amiga
  3. *
  4. * Library initialization, assembler part (PhxAss required)
  5. *
  6. * (C) 1998-2000 Richard Körber <rkoerber@gmx.de>
  7. *
  8. *------------------------------------------------------------------
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. *
  24. * You must not use this source code to gain profit of any kind!
  25. *
  26.  
  27.  
  28.         INCLUDE exec/libraries.i
  29.         INCLUDE exec/initializers.i
  30.         INCLUDE exec/resident.i
  31.         INCLUDE exec/execbase.i
  32.         INCLUDE utility/hooks.i
  33.         INCLUDE lvo/exec.i
  34.  
  35.         INCLUDE PL_Lib.i
  36.  
  37.         SECTION text,CODE
  38.  
  39.         XREF    _LibInit
  40.         XREF    _LibExit
  41.         XREF    _RexxCmd
  42.  
  43.         XREF    _PL_RawSetRate
  44.         XREF    _PL_RawRead
  45.         XREF    _PL_RawWrite
  46.         XREF    _PL_SLPWrite
  47.         XREF    _PL_SLPRead
  48.         XREF    _PL_PADPWrite
  49.         XREF    _PL_PADPRead
  50.         XREF    _PL_CMPAbort
  51.         XREF    _PL_CMPInit
  52.         XREF    _PL_CMPWakeUp
  53.         XREF    _PL_CMPRead
  54.         XREF    _PL_OpenSocket
  55.         XREF    _PL_CloseSocket
  56.         XREF    _PL_LastError
  57.         XREF    _PL_Accept
  58.         XREF    _PL_Connect
  59.         XREF    _PL_Read
  60.         XREF    _PL_Write
  61.         XREF    _PL_Tickle
  62.         XREF    _PL_DLPInit
  63.         XREF    _PL_DLPWriteByte
  64.         XREF    _PL_DLPWriteWord
  65.         XREF    _PL_DLPWriteLong
  66.         XREF    _PL_DLPWrite
  67.         XREF    _PL_DLPSend
  68.         XREF    _PL_DLPRead
  69.         XREF    _DLP_OpenConduit
  70.         XREF    _DLP_EndOfSync
  71.         XREF    _DLP_GetSysTime
  72.         XREF    _DLP_SetSysTime
  73.         XREF    _DLP_GetStorageInfo
  74.         XREF    _DLP_GetSysInfo
  75.         XREF    _DLP_GetDBInfo
  76.         XREF    _DLP_OpenDB
  77.         XREF    _DLP_DeleteDB
  78.         XREF    _DLP_CreateDB
  79.         XREF    _DLP_CloseDB
  80.         XREF    _DLP_CloseAllDB
  81.         XREF    _DLP_CountDBEntries
  82.         XREF    _DLP_MoveCategory
  83.         XREF    _DLP_SetUserInfo
  84.         XREF    _DLP_GetUserInfo
  85.         XREF    _DLP_SetNetSyncInfo
  86.         XREF    _DLP_GetNetSyncInfo
  87.         XREF    _DLP_ResetLastSyncPC
  88.         XREF    _DLP_ResetDBIndex
  89.         XREF    _DLP_GetRecordIDList
  90.         XREF    _DLP_WriteRecord
  91.         XREF    _DLP_DeleteRecord
  92.         XREF    _DLP_DeleteCategory
  93.         XREF    _DLP_ReadResourceByType
  94.         XREF    _DLP_ReadResourceByIndex
  95.         XREF    _DLP_WriteResource
  96.         XREF    _DLP_DeleteResource
  97.         XREF    _DLP_ReadAppBlock
  98.         XREF    _DLP_WriteAppBlock
  99.         XREF    _DLP_ReadSortBlock
  100.         XREF    _DLP_WriteSortBlock
  101.         XREF    _DLP_CleanUpDatabase
  102.         XREF    _DLP_ResetSyncFlags
  103.         XREF    _DLP_ReadNextCatRecord
  104.         XREF    _DLP_ReadAppPreference
  105.         XREF    _DLP_WriteAppPreference
  106.         XREF    _DLP_ReadNextModifiedCatRecord
  107.         XREF    _DLP_ReadRecordByID
  108.         XREF    _DLP_ReadRecordByIndex
  109.         XREF    _DLP_ResetSystem
  110.         XREF    _DLP_AddSyncLogEntry
  111.         XREF    _PL_FileOpen
  112.         XREF    _PL_FileClose
  113.         XREF    _PL_FileGetDBInfo
  114.         XREF    _PL_FileSetDBInfo
  115.         XREF    _PL_FileGetAppInfo
  116.         XREF    _PL_FileSetAppInfo
  117.         XREF    _PL_FileGetSortInfo
  118.         XREF    _PL_FileSetSortInfo
  119.         XREF    _PL_FileReadResource
  120.         XREF    _PL_FileAddResource
  121.         XREF    _PL_FileReadRecord
  122.         XREF    _PL_FileReadRecordID
  123.         XREF    _PL_FileAddRecord
  124.         XREF    _PL_FileUsedID
  125.         XREF    _PL_FileRetrieve
  126.         XREF    _PL_FileInstall
  127.         XREF    _PL_FileMerge
  128.         XREF    _PL_Explain
  129.         XREF    _PL_AddRexxHandle
  130.         XREF    _PL_FindRexxHandle
  131.         XREF    _PL_DeleteRexxHandle
  132.         XREF    _DLP_UnpackCategoryAppInfo
  133.         XREF    _DLP_PackCategoryAppInfo
  134.         XREF    _PL_GetBaudRate
  135.  
  136. *-------------------------------------------------------*
  137. * Start         No start from CLI                       *
  138. *                                                       *
  139. Start           moveq   #0,d0
  140.         rts
  141.  
  142. *-------------------------------------------------------*
  143. * InitDDescrip  Describe Library                        *
  144. *                                                       *
  145. InitDDescrip    dc.w    RTC_MATCHWORD
  146.         dc.l    InitDDescrip
  147.         dc.l    EndCode
  148.         dc.b    RTF_AUTOINIT,VERSION,NT_LIBRARY,0
  149.         dc.l    libname,libidstring,Init
  150. libname         PRGNAME
  151.         dc.b    0
  152. libidstring     VSTRING
  153.  
  154.     ;-- Information for HexReaders... -------------;
  155.  
  156.         VERS
  157.         dc.b    "  (C) 1998-2000 Richard Körber <rkoerber@gmx.de>",13,10,0
  158.         even
  159.  
  160. *-------------------------------------------------------*
  161. * Init          Init Table follows                      *
  162. *                                                       *
  163. Init            dc.l    plb_SIZEOF,FuncTab,DataTab,InitFct
  164.  
  165. *-------------------------------------------------------*
  166. * FuncTab       Table of functions                      *
  167. *  ALWAYS add at its end. NEVER remove or swap lines!!! *
  168. *                                                       *
  169. FuncTab         dc.l    LOpen,LClose,LExpunge,LNull     ;Standard
  170.         dc.l    CallRexxCmd
  171.         dc.l    _PL_RawRead
  172.         dc.l    _PL_RawWrite
  173.         dc.l    _PL_RawSetRate
  174.         dc.l    _PL_SLPRead
  175.         dc.l    _PL_SLPWrite
  176.         dc.l    _PL_PADPRead
  177.         dc.l    _PL_PADPWrite
  178.         dc.l    _PL_CMPRead
  179.         dc.l    _PL_CMPWakeUp
  180.         dc.l    _PL_CMPInit
  181.         dc.l    _PL_CMPAbort
  182.         dc.l    _PL_OpenSocket
  183.         dc.l    _PL_CloseSocket
  184.         dc.l    _PL_LastError
  185.         dc.l    _PL_Accept
  186.         dc.l    _PL_Connect
  187.         dc.l    _PL_Read
  188.         dc.l    _PL_Write
  189.         dc.l    _PL_Tickle
  190.         dc.l    _PL_DLPInit
  191.         dc.l    _PL_DLPWriteByte
  192.         dc.l    _PL_DLPWriteWord
  193.         dc.l    _PL_DLPWriteLong
  194.         dc.l    _PL_DLPWrite
  195.         dc.l    _PL_DLPSend
  196.         dc.l    _PL_DLPRead
  197.         dc.l    _DLP_OpenConduit
  198.         dc.l    _DLP_EndOfSync
  199.         dc.l    _DLP_GetSysTime
  200.         dc.l    _DLP_SetSysTime
  201.         dc.l    _DLP_GetStorageInfo
  202.         dc.l    _DLP_GetSysInfo
  203.         dc.l    _DLP_GetDBInfo
  204.         dc.l    _DLP_OpenDB
  205.         dc.l    _DLP_DeleteDB
  206.         dc.l    _DLP_CreateDB
  207.         dc.l    _DLP_CloseDB
  208.         dc.l    _DLP_CloseAllDB
  209.         dc.l    _DLP_CountDBEntries
  210.         dc.l    _DLP_MoveCategory
  211.         dc.l    _DLP_SetUserInfo
  212.         dc.l    _DLP_GetUserInfo
  213.         dc.l    _DLP_SetNetSyncInfo
  214.         dc.l    _DLP_GetNetSyncInfo
  215.         dc.l    _DLP_ResetLastSyncPC
  216.         dc.l    _DLP_ResetDBIndex
  217.         dc.l    _DLP_GetRecordIDList
  218.         dc.l    _DLP_WriteRecord
  219.         dc.l    _DLP_DeleteRecord
  220.         dc.l    _DLP_DeleteCategory
  221.         dc.l    _DLP_ReadResourceByType
  222.         dc.l    _DLP_ReadResourceByIndex
  223.         dc.l    _DLP_WriteResource
  224.         dc.l    _DLP_DeleteResource
  225.         dc.l    _DLP_ReadAppBlock
  226.         dc.l    _DLP_WriteAppBlock
  227.         dc.l    _DLP_ReadSortBlock
  228.         dc.l    _DLP_WriteSortBlock
  229.         dc.l    _DLP_CleanUpDatabase
  230.         dc.l    _DLP_ResetSyncFlags
  231.         dc.l    _DLP_ReadNextCatRecord
  232.         dc.l    _DLP_ReadAppPreference
  233.         dc.l    _DLP_WriteAppPreference
  234.         dc.l    _DLP_ReadNextModifiedCatRecord
  235.         dc.l    _DLP_ReadRecordByID
  236.         dc.l    _DLP_ReadRecordByIndex
  237.         dc.l    _DLP_ResetSystem
  238.         dc.l    _DLP_AddSyncLogEntry
  239.         dc.l    _PL_FileOpen
  240.         dc.l    _PL_FileClose
  241.         dc.l    _PL_FileGetDBInfo
  242.         dc.l    _PL_FileSetDBInfo
  243.         dc.l    _PL_FileGetAppInfo
  244.         dc.l    _PL_FileSetAppInfo
  245.         dc.l    _PL_FileGetSortInfo
  246.         dc.l    _PL_FileSetSortInfo
  247.         dc.l    _PL_FileReadResource
  248.         dc.l    _PL_FileAddResource
  249.         dc.l    _PL_FileReadRecord
  250.         dc.l    _PL_FileReadRecordID
  251.         dc.l    _PL_FileAddRecord
  252.         dc.l    _PL_FileUsedID
  253.         dc.l    _PL_FileRetrieve
  254.         dc.l    _PL_FileInstall
  255.         dc.l    _PL_FileMerge
  256.         dc.l    _PL_Explain
  257.         dc.l    _PL_AddRexxHandle
  258.         dc.l    _PL_FindRexxHandle
  259.         dc.l    _PL_DeleteRexxHandle
  260.         dc.l    _PL_GetBaudRate
  261.         dc.l    _DLP_UnpackCategoryAppInfo
  262.         dc.l    _DLP_PackCategoryAppInfo
  263.         dc.l    -1                              ;-- End --
  264.  
  265. *-------------------------------------------------------*
  266. * DataTab       Initializes the lib node                *
  267. *                                                       *
  268. DataTab         INITBYTE        LN_TYPE,NT_LIBRARY
  269.         INITLONG        LN_NAME,libname
  270.         INITBYTE        LIB_FLAGS,LIBF_SUMUSED|LIBF_CHANGED
  271.         INITWORD        LIB_VERSION,VERSION
  272.         INITWORD        LIB_REVISION,REVISION
  273.         INITLONG        LIB_IDSTRING,libidstring
  274.         dc.l    0
  275.  
  276. *-------------------------------------------------------*
  277. * InitFct       Initialize Library                      *
  278. *       -» D0.l ^LibBase                                *
  279. *       -» A0.l ^SegList                                *
  280. *       -» A6.l ^SysLibBase                             *
  281. *       «- D0.l ^Libbase                                *
  282. *                                                       *
  283. InitFct         movem.l d1-d7/a0-a6,-(sp)
  284.         move.l  d0,a1                   ;LibBase->a1
  285.         move.l  a6,(plb_SysLib,a1)      ;remember execbase
  286.         move.l  a0,(plb_SegList,a1)     ;remember SegList
  287.         move.l  a6,a0                   ;exec in a0
  288.         jsr     _LibInit                ;own Inits
  289.         movem.l (SP)+,d1-d7/a0-a6
  290.         rts
  291.  
  292. *-------------------------------------------------------*
  293. * LOpen         Open lib                                *
  294. *       -» D0.l Version                                 *
  295. *       -» A6.l ^LibBase                                *
  296. *       «- D0.l ^LibBase, if successful                 *
  297. *                                                       *
  298. LOpen           addq    #1,(LIB_OPENCNT,a6)     ;Increment lib counter
  299.         bclr    #PLLB_DELEXP,(plb_Flags+1,a6) ;Do not close
  300.         move.l  a6,d0
  301.         rts
  302.  
  303. *-------------------------------------------------------*
  304. * LClose        Close Lib                               *
  305. *       -» A6.l ^LibBase                                *
  306. *       «- D0.l ^SegList oder 0                         *
  307. *                                                       *
  308. LClose          moveq   #0,d0
  309.         subq    #1,(LIB_OPENCNT,a6)     ;Decrement lib counter
  310.         bne     .notlast
  311.         btst    #PLLB_DELEXP,(plb_Flags+1,a6) ;Close?
  312.         beq     .notlast
  313.         bsr     LExpunge                ;Yes: expunge
  314. .notlast        rts
  315.  
  316. *-------------------------------------------------------*
  317. * LExpunge      Expunge Lib                             *
  318. *       -» A6.l ^LibBase                                *
  319. *                                                       *
  320. LExpunge        movem.l d7/a5-a6,-(SP)
  321.     ;-- Check state ------------------------;
  322.         move.l  a6,a5
  323.         move.l  (plb_SysLib,a5),a6
  324.         tst     (LIB_OPENCNT,a5)        ;Are we still opened?
  325.         beq     .expimmed
  326. .abort          bset    #PLLB_DELEXP,(plb_Flags+1,a5)  ;Remember to expunge
  327.         moveq   #0,d0                   ;But don't expunge yet
  328.         bra     .exit
  329.     ;-- Lib will be expunged ---------------;
  330. .expimmed       move.l  (plb_SegList,a5),d7     ;Get segment list
  331.         move.l  a5,a1                   ;Remove from list
  332.         exec    Remove
  333.     ;-- Perform own exit method ------------;
  334.         jsr     _LibExit
  335.     ;-- Release memory ---------------------;
  336.         moveq   #0,d0
  337.         move.l  a5,a1
  338.         move    (LIB_NEGSIZE,a5),d0
  339.         sub.l   d0,a1
  340.         add     (LIB_POSSIZE,a5),d0
  341.         exec    FreeMem
  342.     ;-- Done -------------------------------;
  343.         move.l  d7,d0
  344. .exit           movem.l (SP)+,d7/a5-a6
  345.         rts
  346.  
  347. *-------------------------------------------------------*       
  348. * LNull         NOP                                     *
  349. *                                                       *
  350. LNull           moveq   #0,d0
  351.         rts
  352.  
  353. *-------------------------------------------------------*
  354. * Name:         CallRexxCmd                             *
  355. *                                                       *
  356. * Funktion:     ARexx call                              *
  357. *                                                       *
  358. * Parameter:    -» A0.l struct RexxMsg *                *
  359. *               «- A0.l struct RexxArg *RESULT oder NUL *
  360. *               «- D0.l RC                              *
  361. * Register:     Not changed                             *
  362. *                                                       *
  363. * Bemerkungen:                                          *
  364. *>                                                      *
  365. * Revision:     1.0 (26. Oktober 1998, 00:38:04)        *
  366. *                                                       *
  367. CallRexxCmd     movem.l d1-d7/a1-a5,-(SP)
  368.         pea     0.w                     ; Clear one long word on the stack
  369.         move.l  SP,a1                   ; A1 points to this long
  370.         jsr     _RexxCmd                ; Call RexxCmd
  371.         move.l  (SP)+,a0                ; Put result into A0
  372.         movem.l (SP)+,d1-d7/a1-a5
  373.         rts
  374. *<
  375.  
  376. EndCode:
  377.  
  378.         END OF SOURCE
  379.  
  380.